package o2o.web.actions.sys;

import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.jinyou.utils.common.*;
import map.HttpRequest;
import o2o.cache.authrole.AuthMemory;
import o2o.cache.sys.SysCustomerCache;
import o2o.cache.system.SysSettingMemory;
import o2o.cache.system.SysSettingMobileMemory;
import o2o.config.dao.UserDaoSql;
import o2o.config.dao.utils.DaoUtils;
import o2o.config.dao.utils.Expression;
import o2o.config.dao.utils.QueryCondition;
import o2o.dao.PO.PojoTables;
import o2o.dao.PO.authrole.AuthInfo;
import o2o.dao.PO.device.door.DeviceCompanyContact;
import o2o.dao.PO.sys.*;
import o2o.dao.PO.user.UserInfo;
import o2o.dao.VO.authrole.AuthInfoVO;
import o2o.dao.VO.sys.SysSettingMobileVO;
import o2o.dao.VO.sys.SysSettingVO;
import o2o.service.sys.SysSettingService;
import o2o.system.SysSettings;
import o2o.system.data.SYS_CONFIG_PATH;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

//系统设置

@Controller
public class SysSettingsTotalAction {

    //获取所有系统设置
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/pc/settings/list")
    @ResponseBody
    public String sys_pc_list(String apiKey, String sysAppKey, String params, String isShow, String categoryCode) {
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }
            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        List<SysSetting> list = null;
        if (StringUtils.isEmpty(categoryCode)) {
            list = SysSettingMemory.getInstance().list();
        } else {
            list = SysSettingMemory.getInstance().listOfCategoryCode(categoryCode);
        }
        if (ValidateUtil.isAbsList(list)) {
            List<SysSettingVO> voList =
                    list.stream().filter(item -> {
                        if (ValidateUtil.isNotNull(isShow) && !isShow.equals(item.getIsShow())) {
                            return false;
                        }
                        if (ValidateUtil.isNotNull(params) && (!SysCommon.hasKeyword(item.getCode(), params)
                                && !SysCommon.hasKeyword(item.getName(), params)
                                && !SysCommon.hasKeyword(item.getDescs(), params)
                                && !SysCommon.hasKeyword(item.getNote(), params)
                        )) {
                            return false;
                        }
                        return true;
                    }).map(item -> {
                        SysSettingVO sysSettingVO = new SysSettingVO();
                        BeanUtils.copyProperties(item, sysSettingVO);
                        return sysSettingVO;
                    }).collect(Collectors.toList());
//            for (int i = 0; i < list.size(); i++) {
//                if (null == list.get(i)) {
//                    continue;
//                }
//                System.out.println(i);
//                SysSettingVO sysSettingVO = new SysSettingVO();
//                try {
//                    ObjectUtils.copyPropertiesExclude(list.get(i), sysSettingVO, null);
//                } catch (Exception e) {
//                    e.printStackTrace();
//                    continue;
//                }
//                if ((params != null && params != "") && (isShow != null && isShow != "")) {
//                    if ((list.get(i).getCode().indexOf(params) != -1 || list.get(i).getName().indexOf(params) != -1 || list.get(i).getDescs().indexOf(params) != -1 || list.get(i).getNote().indexOf(params) != -1) && String.valueOf(list.get(i).getIsShow()).equals(isShow)) {
//                        voList.add(sysSettingVO);
//                    }
//                } else if (params != null && params != "") {
//                    // 包含
//                    if (list.get(i).getCode().indexOf(params) != -1 || list.get(i).getName().indexOf(params) != -1 || list.get(i).getDescs().indexOf(params) != -1 || list.get(i).getNote().indexOf(params) != -1) {
//                        voList.add(sysSettingVO);
//                    }
//                } else if (isShow != null && isShow != "") {
//                    if (String.valueOf(list.get(i).getIsShow()).equals(isShow)) {
//                        voList.add(sysSettingVO);
//                    }
//                } else {
//                    voList.add(sysSettingVO);
//                }
//            }
            // 排序
            Collections.sort(voList); // 按照isShow降序
            if (ValidateUtil.isAbsList(voList)) {
                return AjaxResult.successResult(voList.size(), voList);
            }
        }

        return AjaxResult.successResult(0, null);
    }

    //  修改系统设置
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/pc/settings/modify")
    @ResponseBody
    public String sys_pc_modify(String apiKey, String sysAppKey, SysSettingVO info) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        if (null == info) {
            return AjaxResult.errorResult("请补全信息");
        }
        if (ValidateUtil.isNull(info.getName())) {
            return AjaxResult.errorResult("名称不能为空");
        }
        SysSetting sysSetting = SysSettingMemory.getInstance().getByCode(info.getName());
        if (null == sysSetting) {
            return AjaxResult.errorResult("未找到该项设置，请查证");
        }
        switch (info.getName()) {
            case "isOpenIntegral": {
                if (info.getVal() != null && "1".equals(info.getVal())) {
                    try {
                        SysSettingService.getInstance().createIntegerShop();
                    } catch (Exception e) {
                        e.printStackTrace();
                        return AjaxResult.errorResult("修改失败,请稍后重试");
                    }
                }
            }
            break;
        }
        StringBuilder sb = new StringBuilder();
        sb.append("update ").append(PojoTables.SYS_SETTING).append(" set val='").append(info.getVal())
                .append("',descs='").append(info.getDescs())
                .append("',isShow='").append(info.getIsShow())
                .append("',categoryCode='").append(info.getCategoryCode())
                .append("',note='").append(info.getNote())
                .append("',valInfo='").append(info.getValInfo())
                .append("',updateUser='").append(user.getUsername())
                .append("' where delFlag = 0 and code = '").append(info.getName()).append("'");
        try {
            UserDaoSql.getInstance().executeBySql(sb.toString());
        } catch (SQLException e) {
            e.printStackTrace();
            return AjaxResult.errorResult("修改失败，请稍后再试");
        }


        //修改缓存
        SysSettings.init();//重新初始化系统值

        return AjaxResult.successResult();
    }

    //  添加系统设置
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/pc/settings/add")
    @ResponseBody
    public String sys_pc_add(String apiKey, String sysAppKey, SysSetting info) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        if (null == info) {
            return AjaxResult.errorResult("请补全信息");
        }
        if (ValidateUtil.isNull(info.getName())) {
            return AjaxResult.errorResult("名称不能为空");
        }
        switch (info.getName()) {
            case "isOpenIntegral": {
                if (info.getVal() != null && "1".equals(info.getVal())) {
                    try {
                        SysSettingService.getInstance().createIntegerShop();
                    } catch (Exception e) {
                        e.printStackTrace();
                        return AjaxResult.errorResult("修改失败,请稍后重试");
                    }
                }
            }
            break;
        }
        try {
            SysSettingDB pc = new SysSettingDB();
            ObjectUtils.copyPropertiesExclude(info, pc, null);
            pc.setCreateUser("admin");
            pc.setCreateTime(DateUtils.getCurrTime());
            UserDaoSql.getInstance().insertObj(PojoTables.SYS_SETTING, pc);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult("新增失败，请联系管理员");
        }
        SysSettings.init();//重新初始化系统值
        return AjaxResult.successResult();
    }

    //  批量添加系统设置
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/pc/settings/addList")
    @ResponseBody
    public String sys_pc_addList(String apiKey, String sysAppKey, String addJson) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        if (StringUtils.isBlank(addJson)) {
            return AjaxResult.errorResult("json串参数不能为空");
        }

        // 取缓存
        List<SysSetting> list = SysSettingMemory.getInstance().list();

        List<SysSetting> sysSettingList = JSON.parseArray(addJson, SysSetting.class);
        if (ValidateUtil.isAbsList(sysSettingList)) {
            for (SysSetting info : sysSettingList) {
                if (null == info) {
                    continue;
                }
                if (ValidateUtil.isNull(info.getName())) {
                    return AjaxResult.errorResult("名称不能为空");
                }

                // 重复的name跳过
                if (ValidateUtil.isAbsList(list)) {
                    for (SysSetting sysSetting : list) {
                        if (info.getName().equals(sysSetting.getName())) {
                            break;
                        }
                    }
                }
                switch (info.getName()) {
                    case "isOpenIntegral": {
                        if (info.getVal() != null && "1".equals(info.getVal())) {
                            try {
                                SysSettingService.getInstance().createIntegerShop();
                            } catch (Exception e) {
                                e.printStackTrace();
                                return AjaxResult.errorResult("修改失败,请稍后重试");
                            }
                        }
                    }
                    break;
                }
                try {
                    SysSettingDB pc = new SysSettingDB();
                    ObjectUtils.copyPropertiesExclude(info, pc, null);
                    pc.setCreateUser("admin");
                    pc.setCreateTime(DateUtils.getCurrTime());
                    pc.setUpdateTime(null);
                    UserDaoSql.getInstance().insertObj(PojoTables.SYS_SETTING, pc);
                } catch (Exception e) {
                    e.printStackTrace();
                    return AjaxResult.errorResult("新增失败，请联系管理员");
                }
                SysSettings.init();//重新初始化系统值
            }
        }
        return AjaxResult.successResult();
    }

    //  纯sql
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/pc/sql/add")
    @ResponseBody
    public String sys_sql_add(String apiKey, String sysAppKey, String sql) {
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        try {
            UserDaoSql.getInstance().executeBySql(sql);
        } catch (SQLException e) {
            e.printStackTrace();
            return AjaxResult.errorResult("添加失败，请稍后再试");
        }
        SysSettings.init();//重新初始化系统值
        return AjaxResult.successResult();
    }


    //  添加系统设置
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/all/settings/add")
    @ResponseBody
    public String sys_all_add(String apiKey, String sysAppKey, String itemPC, String itemMobile) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        // 新增手机端
        List<SysSettingMobile> mobileList = JSON.parseArray(itemMobile, SysSettingMobile.class);
        if (ValidateUtil.isAbsList(mobileList)) {
            for (SysSettingMobile mobile : mobileList) {
                // 是否存在
                boolean isExist = false;
                // 获取手机端配置信息
                List<SysSettingMobile> list = SysSettingMobileMemory.getInstance().listOfAll();
                if (ValidateUtil.isAbsList(list)) {
                    for (int i = 0; i < list.size(); i++) {
                        if (null == list.get(i)) {
                            continue;
                        }
                        if (list.get(i).getName().equals(mobile.getName())) {
                            isExist = true;
                            break;
                        }
                        if (list.get(i).getCode().equals(mobile.getCode())) {
                            isExist = true;
                            break;
                        }
                    }
                }
                // 如果已经存在则跳过
                if (isExist) {
                    continue;
                }
                try {
                    mobile.setCreateUser("admin");
                    mobile.setCreateTime(DateUtils.getCurrTime());
                    mobile.setId(null);
                    if (mobile.getNote() == null || "".equals(mobile.getNote())) {
                        mobile.setNote(null);
                    }
                    if (mobile.getGroup() == null || "".equals(mobile.getGroup())) {
                        mobile.setGroup(null);
                    }
                    UserDaoSql.getInstance().insertObj(PojoTables.SYS_SETTING_MOBILE, mobile);
                } catch (SQLException e) {
                    e.printStackTrace();
                    return AjaxResult.errorResult("新增失败，请稍后再试");
                }
            }
        }

        // 新增PC端
        List<SysSettingDB> PCList = JSON.parseArray(itemPC, SysSettingDB.class);
        if (ValidateUtil.isAbsList(PCList)) {
            for (SysSettingDB pc : PCList) {
                // 是否存在
                boolean isExist = false;
                // 获取手机端配置信息
                List<SysSetting> list = SysSettingMemory.getInstance().list();
                if (ValidateUtil.isAbsList(list)) {
                    for (int i = 0; i < list.size(); i++) {
                        if (null == list.get(i)) {
                            continue;
                        }
                        if (list.get(i).getName().equals(pc.getName())) {
                            isExist = true;
                            break;
                        }
                        if (list.get(i).getCode().equals(pc.getCode())) {
                            isExist = true;
                            break;
                        }
                    }
                }
                // 如果已经存在则跳过
                if (isExist) {
                    continue;
                }
                try {
                    pc.setCreateUser("admin");
                    pc.setCreateTime(DateUtils.getCurrTime());
                    UserDaoSql.getInstance().insertObj(PojoTables.SYS_SETTING, pc);
                } catch (SQLException e) {
                    e.printStackTrace();
                    return AjaxResult.errorResult("新增失败，请稍后再试");
                }
            }
        }

        SysSettings.init();//重新初始化系统值
        return AjaxResult.successResult();
    }

    //  添加PC系统设置
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/all/settings/addpc")
    @ResponseBody
    public String sys_pc_add(String apiKey, String sysAppKey, String itemPC) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        // 新增PC端
        List<SysSettingDB> PCList = JSON.parseArray(itemPC, SysSettingDB.class);
        if (ValidateUtil.isAbsList(PCList)) {
            for (SysSettingDB pc : PCList) {
                // 是否存在
                boolean isExist = false;
                // 获取手机端配置信息
                List<SysSetting> list = SysSettingMemory.getInstance().list();
                if (ValidateUtil.isAbsList(list)) {
                    for (int i = 0; i < list.size(); i++) {
                        if (null == list.get(i)) {
                            continue;
                        }
                        if (list.get(i).getName().equals(pc.getName())) {
                            isExist = true;
                            break;
                        }
                        if (list.get(i).getCode().equals(pc.getCode())) {
                            isExist = true;
                            break;
                        }
                    }
                }
                // 如果已经存在则跳过
                if (isExist) {
                    continue;
                }
                try {
                    pc.setCreateUser("admin");
                    pc.setCreateTime(DateUtils.getCurrTime());
                    UserDaoSql.getInstance().insertObj(PojoTables.SYS_SETTING, pc);
                } catch (SQLException e) {
                    e.printStackTrace();
                    return AjaxResult.errorResult("新增失败，请稍后再试");
                }
            }
        }
        SysSettings.init();//重新初始化系统值
        return AjaxResult.successResult();
    }

    //  添加手机端系统设置
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/all/settings/addmobile")
    @ResponseBody
    public String sys_mobile_add(String apiKey, String sysAppKey, String itemMobile) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        // 新增手机端
        List<SysSettingMobile> mobileList = JSON.parseArray(itemMobile, SysSettingMobile.class);
        if (ValidateUtil.isAbsList(mobileList)) {
            for (SysSettingMobile mobile : mobileList) {
                // 是否存在
                boolean isExist = false;
                // 获取手机端配置信息
                List<SysSettingMobile> list = SysSettingMobileMemory.getInstance().listOfAll();
                if (ValidateUtil.isAbsList(list)) {
                    for (int i = 0; i < list.size(); i++) {
                        if (null == list.get(i)) {
                            continue;
                        }
                        if (list.get(i).getName().equals(mobile.getName())) {
                            isExist = true;
                            break;
                        }
                        if (list.get(i).getCode().equals(mobile.getCode())) {
                            isExist = true;
                            break;
                        }
                    }
                }
                // 如果已经存在则跳过
                if (isExist) {
                    continue;
                }
                try {
                    mobile.setCreateUser("admin");
                    mobile.setCreateTime(DateUtils.getCurrTime());
                    mobile.setId(null);
                    if (mobile.getNote() == null || "".equals(mobile.getNote())) {
                        mobile.setNote(null);
                    }
                    if (mobile.getGroup() == null || "".equals(mobile.getGroup())) {
                        mobile.setGroup(null);
                    }
                    UserDaoSql.getInstance().insertObj(PojoTables.SYS_SETTING_MOBILE, mobile);
                } catch (SQLException e) {
                    e.printStackTrace();
                    return AjaxResult.errorResult("新增失败，请稍后再试");
                }
            }
        }
        SysSettings.init();//重新初始化系统值
        return AjaxResult.successResult();
    }

    //----------------------------------手机端--------------------------------
    //获取所有系统设置手机端
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/base/mobile/settings/list")
    @ResponseBody
    public String sys_list(String apiKey, String sysAppKey, String params, String isShow, String categoryCode) {
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        List<SysSettingMobile> list = new ArrayList<>();
        if (StringUtils.isEmpty(categoryCode)) {
            list = SysSettingMobileMemory.getInstance().listOfAll();
        } else {
            list = SysSettingMobileMemory.getInstance().listOfCategoryCode(categoryCode);
        }
        if (ValidateUtil.isAbsList(list)) {
            List<SysSettingMobileVO> voList = list.stream().filter(item -> {
                if (ValidateUtil.isNotNull(isShow) && !isShow.equals(item.getIsShow())) {
                    return false;
                }
                if (ValidateUtil.isNotNull(params) && (!SysCommon.hasKeyword(item.getCode(), params)
                        && !SysCommon.hasKeyword(item.getName(), params)
                        && !SysCommon.hasKeyword(item.getDescs(), params)
                        && !SysCommon.hasKeyword(item.getNote(), params)
                )) {
                    return false;
                }
                return true;
            }).map(item -> {
                SysSettingMobileVO sysSettingVO = new SysSettingMobileVO();
                BeanUtils.copyProperties(item, sysSettingVO);
                return sysSettingVO;
            }).collect(Collectors.toList());
            // 排序
            Collections.sort(voList); // 按照isShow降序
            if (ValidateUtil.isAbsList(voList)) {
                return AjaxResult.successResult(voList.size(), voList.size(), voList);
            }
        }
        return AjaxResult.successResult(0, 0, null);
    }

    //修改系统设置手机端
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/base/mobile/settings/modify")
    @ResponseBody
    public String sys_modify(String apiKey, String sysAppKey, SysSettingMobileVO info) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }
            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }

        if (null == info) {
            return AjaxResult.errorResult("请补全信息");
        }

        if (ValidateUtil.isNull(info.getCode())) {
            return AjaxResult.errorResult("code不能为空");
        }


        SysSettingMobile sysSetting = SysSettingMobileMemory.getInstance().getByCode(info.getCode());
        if (null == sysSetting) {
            return AjaxResult.errorResult("未找到该项设置，请查证");
        }
        Connection con = null;
        StringBuilder sb = new StringBuilder();
        sb.append("update ").append(PojoTables.SYS_SETTING_MOBILE).append(" set val='").append(info.getVal())
                .append("',descs='").append(info.getDescs())
                .append("',name='").append(info.getName())
                .append("',note='").append(info.getNote())
                .append("',isShow='").append(info.getIsShow())
                .append("',categoryCode='").append(info.getCategoryCode())
                .append("',updateUser='").append(null == user ? "" : user.getUsername())
                .append("' where delFlag = 0 and code = '").append(info.getCode()).append("'");
        try {
            con = UserDaoSql.getInstance().getConnection();
            con.setAutoCommit(false);
            if (info.getCode().equals(SysSettingMobileConstant.DISTRIBUTION_MODEL)) {
                this.updateRemotePlateDistribute(info.getVal());
            }
            UserDaoSql.getInstance().executeBySql(sb.toString());
            con.commit();
        } catch (Exception e) {
            e.printStackTrace();
            UserDaoSql.getInstance().rollback(con);
            return AjaxResult.errorResult("修改失败，请稍后再试");
        } finally {
            UserDaoSql.getInstance().close(con);
        }
        //修改缓存
        SysSettingMobileMemory.getInstance().modifyByCode(info.getCode());//修改信息
        SysSettings.init();//重新初始化系统值
        return AjaxResult.successResult();
    }

    //新增系统参数手机端
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/base/mobile/settings/add")
    @ResponseBody
    public String sys_add(String apiKey, String sysAppKey, SysSettingMobile info) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }
            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        if (null == info) {
            return AjaxResult.errorResult("请补全信息");
        }

        if (ValidateUtil.isNull(info.getCode())) {
            return AjaxResult.errorResult("code不能为空");
        }


        SysSettingMobile sysSetting = SysSettingMobileMemory.getInstance().getByCode(info.getCode());
        if (null != sysSetting) {
            return AjaxResult.errorResult("code 已存在，请更换");
        }

        if (null != user) {
            info.setCreateUser(null == user ? "" : user.getUsername());
        }
        info.setCreateTime(DateUtils.getCurrTime());
        Connection con = null;
        try {
            con = UserDaoSql.getInstance().getConnection();
            con.setAutoCommit(false);
            if (info.getCode().equals(SysSettingMobileConstant.DISTRIBUTION_MODEL)) {
                this.updateRemotePlateDistribute(info.getVal());
            }
//            UserDaoSql.getInstance().insertObj(PojoTables.SYS_SETTING_MOBILE, info);
            UserDaoSql.getInstance().saveObj(PojoTables.SYS_SETTING_MOBILE, info, con);
            con.commit();
        } catch (Exception e) {
            UserDaoSql.getInstance().rollback(con);
            e.printStackTrace();
            return AjaxResult.errorResult("新增失败，请联系管理员");
        } finally {
            UserDaoSql.getInstance().close(con);
        }
        //修改缓存
        SysSettingMobileMemory.getInstance().modifyByCode(info.getCode());//修改信息
        SysSettings.init();//重新初始化系统值
        return AjaxResult.successResult();
    }

    // 批量新增系统参数手机端
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/base/mobile/settings/addList")
    @ResponseBody
    public String sys_addList(String apiKey, String sysAppKey, String addJson) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }
            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }

        // 取缓存
        List<SysSettingMobile> mobileList = SysSettingMobileMemory.getInstance().listOfAll();

        List<SysSettingMobile> sysSettingMobileList = JSON.parseArray(addJson, SysSettingMobile.class);
        if (ValidateUtil.isAbsList(sysSettingMobileList)) {
            for (SysSettingMobile info : sysSettingMobileList) {

                // 重复name跳过
                if (ValidateUtil.isAbsList(mobileList)) {
                    for (SysSettingMobile sysSettingMobile : mobileList) {
                        if (sysSettingMobile.getName().equals(info.getName())) {
                            break;
                        }
                    }
                }

                if (null != user) {
                    info.setCreateUser(null == user ? "" : user.getUsername());
                }
                info.setId(null);
                info.setDelFlag(0);
                info.setCreateTime(DateUtils.getCurrTime());

                Connection con = null;
                try {
                    con = UserDaoSql.getInstance().getConnection();
                    con.setAutoCommit(false);
                    UserDaoSql.getInstance().saveObj(PojoTables.SYS_SETTING_MOBILE, info, con);
                    con.commit();
                } catch (Exception e) {
                    UserDaoSql.getInstance().rollback(con);
                    e.printStackTrace();
                    return AjaxResult.errorResult("新增失败，请联系管理员");
                } finally {
                    UserDaoSql.getInstance().close(con);
                }
                //修改缓存
                SysSettingMobileMemory.getInstance().modifyByCode(info.getCode());//修改信息
                SysSettings.init();//重新初始化系统值
            }
        }
        return AjaxResult.successResult();
    }

    // 远程 修改远程分销模式
    public void updateRemotePlateDistribute(String value) throws Exception {
        // 全民分销
        if (ValidateUtil.isNotNull(value)) {
            Integer distributeState = 1;
            if (value.equals("1")) {
                distributeState = 2;
            }
            String note = "分销模式 1 全民分销 2部分分销";
            String requestStr = HttpRequest.sendPost(SYS_CONFIG_PATH.FEN_XIAO_SERVICE_URL + "/api/distribute/system/setting/update-distribute-model"
                    , "param=distribute_model" + "&parVal=" + distributeState + "&note=" + note + "&sysCustomer=" + SYS_CONFIG_PATH.FEN_XIAO_SERVICE_KEY);
            DeviceCompanyContact companyContact = new Gson().fromJson(requestStr, DeviceCompanyContact.class);
            if (null == companyContact || 0 == companyContact.getStatus()) {
                throw new Exception("分销模式修改失败");
            }
            if (0 == 1 - companyContact.getStatus()) {
                System.out.println("分销模式修改成功");
            }
        }
    }

//  --------------------------------------权限管理--------------------------


    //获取所有系统权限
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/base/auth/list")
    @ResponseBody
    public String sys_auth_list(String apiKey, String sysAppKey, String params, String isShow, String type) {
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
//        List<AuthInfo> list = AuthMemory.getInstance().listAll();
        QueryCondition query = new QueryCondition();
        if (StringUtils.isNotEmpty(isShow)) {
            query.addCondition(Expression.getInstance().addChild("delFlag", isShow));
        } else if (StringUtils.isNotEmpty(type)) {
            query.addCondition(Expression.getInstance().addChild("type", type));
        } else {
            query.addCondition(Expression.getInstance());
        }
        String sql = DaoUtils.getSql(PojoTables.AUTH_INFO, query);
        List<AuthInfo> list = null;
        try {
            list = (List<AuthInfo>) UserDaoSql.getInstance().list(AuthInfo.class, sql);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        if (ValidateUtil.isAbsList(list)) {
//            List<AuthInfoVO> voList = new ArrayList<>();
//            for (AuthInfo info : list) {
//                if (info == null) {
//                    continue;
//                }
//                AuthInfoVO infoVO = new AuthInfoVO();
//                try {
//                    ObjectUtils.copyPropertiesExclude(info, infoVO);
//                } catch (Exception e) {
//                    e.printStackTrace();
//                    continue;
//                }
//
//
//                if ((params != null && params != "") && (isShow != null && isShow != "")) {
//                    if ((info.getCode().indexOf(params) != -1 || info.getName().indexOf(params) != -1 || info.getShowName().indexOf(params) != -1 || info.getLabel().indexOf(params) != -1) && String.valueOf(info.getDelFlag()).equals(isShow)) {
//                        voList.add(infoVO);
//                    }
//                } else if (params != null && params != "") {
//                    // 包含
//                    if (info.getCode().indexOf(params) != -1 || info.getName().indexOf(params) != -1 || info.getShowName().indexOf(params) != -1 || info.getLabel().indexOf(params) != -1) {
//                        voList.add(infoVO);
//                    }
//                } else if (isShow != null && isShow != "") {
//                    if (String.valueOf(info.getDelFlag()).equals(isShow)) {
//                        voList.add(infoVO);
//                    }
//                } else {
//                    voList.add(infoVO);
//                }
//            }
            List<AuthInfoVO> voList = list.stream().map(item -> {
                AuthInfoVO infoVO = new AuthInfoVO();
                BeanUtils.copyProperties(item, infoVO);
                return infoVO;
            }).filter(item -> {
                if (item == null) {
                    return false;
                }
                if (ValidateUtil.isNotNull(isShow) && !isShow.equals(item.getDelFlag())) {
                    return false;
                }
                if (ValidateUtil.isNotNull(params)
                        && !SysCommon.hasKeyword(item.getName(), params)
                        && !SysCommon.hasKeyword(item.getLabel(), params)
                        && !SysCommon.hasKeyword(item.getShowName(), params)
                ) {
                    return false;
                }
                return true;
            }).collect(Collectors.toList());
            // 排序
            Collections.sort(voList, Comparator.comparingInt(AuthInfoVO::getDelFlag)); // 按照isShow降序
            if (ValidateUtil.isAbsList(voList)) {
                return AjaxResult.successResult(voList.size(), voList.size(), voList);
            }
        }
        return AjaxResult.successResult(0, 0, null);
    }

    //新增权限
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/base/auth/add")
    @ResponseBody
    public String sys_auth_add(String apiKey, String sysAppKey, AuthInfo info) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }
            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        if (null == info) {
            return AjaxResult.errorResult("请补全信息");
        }

        if (ValidateUtil.isNull(info.getCode())) {
            return AjaxResult.errorResult("code不能为空");
        }


        AuthInfo sysSetting = AuthMemory.getByCode(info.getCode());
        if (null != sysSetting) {
            return AjaxResult.errorResult("code 已存在，请更换");
        }

        if (null != user) {
            info.setCreateUser(null == user ? "" : user.getUsername());
        }
        info.setCreateTime(DateUtils.getCurrTime());
        try {
            UserDaoSql.getInstance().insertObj(PojoTables.AUTH_INFO, info);
        } catch (SQLException e) {
            e.printStackTrace();
            return AjaxResult.errorResult("新增失败，请稍后再试");
        }

        return AjaxResult.successResult();
    }

    //修改权限
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/base/auth/update")
    @ResponseBody
    public String sys_auth_update(String apiKey, String sysAppKey, AuthInfo info) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }
            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }

        if (null == info) {
            return AjaxResult.errorResult("请补全信息");
        }

        if (ValidateUtil.isNull(info.getCode())) {
            return AjaxResult.errorResult("code不能为空");
        }

        StringBuilder sb = new StringBuilder();

        sb.append("update ").append(PojoTables.AUTH_INFO)
                .append(" set name='").append(info.getName())
                .append("',showName='").append(info.getShowName())
                .append("',label='").append(info.getLabel())
                .append("',path='").append(info.getPath())
                .append("',icon='").append(info.getIcon())
                .append("',type='").append(info.getType())
                .append("',isAdminCanOwn='").append(info.getIsAdminCanOwn())
                .append("',isNavTag='").append(info.getIsNavTag())
                .append("',delFlag='").append(info.getDelFlag())
                .append("',note='").append(info.getNote())
                .append("',updateUser='").append(null == user ? "" : user.getUsername())
                .append("' where id = '").append(info.getId()).append("'");
        try {
            UserDaoSql.getInstance().executeBySql(sb.toString());
        } catch (SQLException e) {
            e.printStackTrace();
            return AjaxResult.errorResult("修改失败，请稍后再试");
        }

        return AjaxResult.successResult();
    }

    //  添加同步全部权限
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/base/auth/all/add")
    @ResponseBody
    public String sys_auth_all_add(String apiKey, String sysAppKey, String itemAuth) {
        UserInfo user = new UserInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            SysCustomerInfo customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
            user.setUsername("admin");
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }
        // 新增权限
        List<AuthInfo> authList = JSON.parseArray(itemAuth, AuthInfo.class);
        if (ValidateUtil.isAbsList(authList)) {
            for (AuthInfo info : authList) {
                // 是否存在
                boolean isExist = false;
                // 获取权限配置信息
//                List<AuthInfo> list = AuthMemory.getInstance().listAll();
                QueryCondition query = new QueryCondition();
                query.addCondition(Expression.getInstance());
                String sql = DaoUtils.getSql(PojoTables.AUTH_INFO, query);
                List<AuthInfo> list = null;
                try {
                    list = (List<AuthInfo>) UserDaoSql.getInstance().list(AuthInfo.class, sql);
                } catch (SQLException e) {
                    e.printStackTrace();
                }
                if (ValidateUtil.isAbsList(list)) {
                    for (int i = 0; i < list.size(); i++) {
                        if (null == list.get(i)) {
                            continue;
                        }
                        if (list.get(i).getName().equals(info.getName())) {
                            isExist = true;
                            break;
                        }
                        if (list.get(i).getCode().equals(info.getCode())) {
                            isExist = true;
                            break;
                        }
                    }
                }
                // 如果已经存在则跳过
                if (isExist) {
                    continue;
                }
                info.setCreateUser("admin");
                info.setId(null);
                info.setCreateTime(DateUtils.getCurrTime());
                // 当类型为公共模块的时候默认不开启
                if (info.getType() == 0 || info.getType() == 5) {
                    info.setDelFlag(0);
                }
                try {
                    UserDaoSql.getInstance().insertObj(PojoTables.AUTH_INFO, info);
                } catch (SQLException e) {
                    e.printStackTrace();
                    return AjaxResult.errorResult("新增失败，请稍后再试");
                }
            }
        }

        return AjaxResult.successResult();
    }

    //-------------------------------------客户标识-----------------------------------------------------------------------------------------------------
    //  获取 客户标识配置
    @RequestMapping(method = RequestMethod.POST, value = "/admin/base/sys/customer/info")
    @ResponseBody
    public String sys_customer(String apiKey, String sysAppKey) {
        UserInfo user = new UserInfo();
        SysCustomerInfo customerInfo = new SysCustomerInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }

        return AjaxResult.successResult(customerInfo);
    }

    //  获取 客户标识apiKey
    @RequestMapping(method = RequestMethod.POST, value = "/admin/base/get/sys-customer/key")
    @ResponseBody
    public String sys_customer(String sysAppKey) {
        UserInfo user = new UserInfo();
        SysCustomerInfo customerInfo = new SysCustomerInfo();
        try {
            customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null == customerInfo) {
                return AjaxResult.errorResult("没有客户信息");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }

        return AjaxResult.successResult(customerInfo.getApiKey());
    }

    //  获取 客户标识配置
    @RequestMapping(method = RequestMethod.POST, value = "/admin/base/sys/customer/update")
    @ResponseBody
    public String sys_customer_update(String apiKey, String sysAppKey, SysCustomerInfo info) {
        UserInfo user = new UserInfo();
        SysCustomerInfo customerInfo = new SysCustomerInfo();
        try {
            String decrypt = EncrypAES.aesDecrypt(apiKey, "abcdefgabcdeg12p");
            if (ValidateUtil.isNull(sysAppKey)) {
                sysAppKey = SysCustomerCache.getInstance().getDefaultKey();
            }

            customerInfo = SysCustomerCache.getInstance().getInfo(sysAppKey);
            if (null != customerInfo) {
                if (!decrypt.equals(customerInfo.getApiKey())) {
                    return AjaxResult.errorResult("您没有访问权限");
                }
            } else {
                return AjaxResult.errorResult("没有客户信息");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult(e.getMessage());
        }

        // 更新
        StringBuffer sql = new StringBuffer();
        sql.append("update ").append(PojoTables.SYS_CUSTOMER_INFO).append(" set ")
                .append(" updateUser = '").append("base").append("'");
        if (info.getName() != null) {//客户名称
            sql.append(",name = '").append(info.getName()).append("'");
        }
        if (info.getSmsKey() != null) {//使用的短信标识
            sql.append(",smsKey = '").append(info.getSmsKey()).append("'");
        }
        if (info.getSmsProduct() != null) {//发送短信时名称
            sql.append(",smsProduct = '").append(info.getSmsProduct()).append("'");
        }
        if (info.getSmsKeyOut() != null) {//使用的短信标识  (国际版)
            sql.append(",smsKeyOut = '").append(info.getSmsKeyOut()).append("'");
        }
        if (info.getSmsProductOut() != null) {//发送短信时名称 (国际版)
            sql.append(",smsProductOut = '").append(info.getSmsProductOut()).append("'");
        }
        if (info.getPhoneKey() != null) {// 电话通知服务标识
            sql.append(",phoneKey = '").append(info.getPhoneKey()).append("'");
        }
        if (info.getJpushPhonePrefix() != null) {// 智慧商户，手机号推送前缀（智慧商户时，推送标识）
            sql.append(",jpushPhonePrefix = '").append(info.getJpushPhonePrefix()).append("'");
        }
        sql.append(" where ").append(" id ='").append(info.getId()).append("'");
        sql.append(" and delFlag = 0");
        try {
            UserDaoSql.getInstance().executeBySql(sql.toString());
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult("更新失败，请稍后重试");
        }
        // 重新加载
        SysCustomerCache.getInstance().load();
        return AjaxResult.successResult();
    }
}
